Okay, Let's talk about the roadblocks data types in this video.
There are several, but the ones I want to mention here are going to be the ones you'll use the most
often.
The first data type is vector three and vector three stores, three numbers that correspond to a vector
in three space.
What is a vector?
Well, you can think of it as an arrow in three d space that has a direction basically where it's pointing
and it has a magnitude, which is the length of the arrow and roadblocks.
We can use vector threes as a way to define a point in 3D space or define a direction in three d space.
The vector three data type holds three values that correspond to the X, Y, and Z coordinate.
The next is much simpler, and that's color three.
And this data type allows you to hold three numbers that represent the red, green and blue color values
to make up over 16.8 million different colors.
You'll use this data type all the time for changes in the color of parts, your eyes and a lot more.
Instance, is another simple data type, and it's only used as a constructor that it has to create new
instance objects like creating a new part, a new explosion, a new UI, whatever the case may be.
The enum data type is short for enumeration or enumerated type.
What the heck is an enumerated type?
Well, enemies are used to define constants that represent a particular thing.
So, for example, when you spawn a part in your game, it usually spawns as a rectangle.
But what if I wanted to change the shape?
Well, the part has a property that you can access.
And it's called Shape, and it takes an enumerated type.
And based on that, it changes the part shape to a constant defined within the enum.
Like I have a ball, a block cylinder, and there's other extra ones like wedges in the model menu here
for spawning parts.
Another examples that you can use enemies to declare the types of things in your game, like how many
different types of ores are in your game, like Diamond and Emerald and silver?
Or what types of weapons are your game like Sword Hammer, whatever else the case may be.
All it does is hold defined constants.
The next data type is random, and this one will just simply use to get pseudo random numbers.
This is better than using math at random because it's more unpredictable.
And then lastly is see frame.
And this is short for coordinate frame and it holds two vector three values, one that stands for a
position and one that stands for the rotation.
It also holds the look vector, right vector and up vector of the C frame.
And those define the vectors, the direction that they are facing.
So one's looking to the left, ones looking to the right, one's looking up, one's looking down, one
looking forward.
That's kind of the data it holds.
We'll learn more about see frames in the next video.
So let's go ahead and see an example of the vector three data type here.
To see the vector three data type, I'll create a variable called position, and then I can use the
vector three keyword and use the dot new function to create a new vector three object.
And I can pass a value like five, five and five.
Let's just do that.
And now this returns to me a table that holds this position as well as a table that allows me to do
things like add vectors together.
So as we saw previously with using tables and meta tables, Roblox is doing the exact same thing here
with their custom data type.
And now using this position, I can take a part in my game.
Let's click my game real quick.
Maybe this big yellow part right here.
On rename it to yellow part.
And then I can go back to my script.
And then I could do workspace, find my yellow part, and then I can set the position of this part to
my new vector three.
And I want to make sure that my part is also anchored so it doesn't fall.
Now, if I run the game, this part should move from its position of 55 6.5 and -51 to a new position
of five, five, five.
Let's hit run.
And you see, my part has disappeared.
And now it is at the position of five, five, five.
Now let's say I want to change the color of my part to, well, I can create another variable or actually,
I won't create a variable at all.
I'll just index the workspace again, get access to my part.
And then I'll index the property color.
And then I can set this color to a new color three value.
So I'll use the keyword color three.
And then there's several functions in here.
We have new from our GB, HSV and hexadecimal.
And for simplicity's sake, I'm going to use rugby, which gives you numbers to pick from starting at
zero all the way up to 255 for red, green and blue.
And they have this little cool button here that I can do.
And pick my own color so I don't actually have to type the numbers in.
So maybe I want it to be kind of like neon green, I guess.
And it automatically puts the numbers.
And now if I run my game, this part should change from yellow to green.
Perfect.
Now the next type is instance.
And this one is very simple.
If I use the keyword instance.
And then access the new function.
I can pass a class name, which is a string of the new instance I want to create.
So maybe I want to create another part, a new part, and then I can actually pass another argument
which sets the parent of the part.
But usually you want to set the parent after you're done manipulating the part.
Because if I set the parent immediately to the workspace, this part by default is unanchored, so it
actually fall.
Instead, I want to have my part be anchored first so I can store the return of this function in a variable.
I'll call it new part.
And then I'll set a new part to be anchored.
And then I'll set the position of new part.
And this new position will be a new vector three, and I'll set it to maybe 15, 15, 15.
And then I can set the parent of my part to the workspace so that way we can actually see it in the
game.
Now, if I run the game again.
We should see our new part somewhere.
There it is.
Here is our new part.
Now let's go ahead and see the enumerator data type.
So with my new part that I've created, maybe I want to change the shape of it so I can do new part
and go to dot shape.
And you can see it requires an enum of part type.
So I can access these enemies by using the enum keyword.
I can go to part type and in here it defines three different enemies that I can change it to.
I can change to a cylinder, a ball or a block.
So I'll just make it into a ball.
And now if I run my game again, our new part should be a sphere.
Here we go.
And now the last data type I'm going to show here is random.
And this one's very simple.
Again, you do random create a new random data type.
And I'll actually store it in a variable.
I'll call it R and G.
And using this variable, I can generate whatever random number I'd like.
So maybe for my new part, I actually want to change the color to something random, Completely random.
So I'll do color.
I'll use the color three data type again.
So I can pass the random data type and use a function in it that's called next integer.
And I can pass a minimum number and a maximum number in this case, since we're going to be using actually
from our GB instead of new, we're going to be limited to 0 to 255.
So I'll put in zero 255 and it will pick a random number between it and then I can just copy this function.
And do it three more times or two more times.
We have a total of three.
And now the color of this object should be completely random.
See what color we got.
We got a weird puke greenish black.
But if I stop the test and run it again, we should get a completely different color.
This time, we kind of got a reddish orange.
Find the test and run it again.
We get a nice purple color.
All right.
So that's pretty much the basics of these robots data types.
I just wanted to expose you to these data types because you're going to be using them a lot.
And in the next video, we're going to learn all about see frames.
I'll see you there.